home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / Vector4.h < prev   
Encoding:
C/C++ Source or Header  |  2005-11-25  |  2.3 KB  |  85 lines

  1.  
  2.  
  3. #ifndef __VECTOR4_H_
  4. #define __VECTOR4_H_
  5. /*
  6. Peon - Win32 Games Programming Library
  7. Copyright (C) 2002-2005 Erik Yuzwa
  8.  
  9. This library is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU Library General Public
  11. License as published by the Free Software Foundation; either
  12. version 2 of the License, or (at your option) any later version.
  13.  
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. Library General Public License for more details.
  18.  
  19. You should have received a copy of the GNU Library General Public
  20. License along with this library; if not, write to the Free
  21. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  22.  
  23. Erik Yuzwa
  24. peon AT wazooinc DOT com
  25. */
  26.  
  27. #include "Peonstdafx.h"
  28.  
  29. namespace peon
  30. {
  31.     /**
  32.     * This object is used as a 4-tuple. So far it's mainly just used for
  33.     * lighting purposes in the @SceneLight object, but it could also perhaps
  34.     * be used to store RGBA color information...
  35.     *
  36.     */
  37.     class PEONMAIN_API Vector4
  38.     {
  39.     public:
  40.         /** x component */
  41.         float x;
  42.  
  43.         /** y component */
  44.         float y;
  45.  
  46.         /** z component */
  47.         float z;
  48.  
  49.         /** w component */
  50.         float w;
  51.  
  52.         Vector4(float x_ = 0.0f, float y_ = 0.0f, float z_ = 0.0f, float w_ = 0.0f);
  53.         ~Vector4();
  54.  
  55.         void set(float x_, float y_, float z_, float w_);
  56.         float length(void);
  57.         void normalize(void);
  58.  
  59.         // Static utility methods
  60.         static float distance(const Vector4 &v1, const Vector4 &v2);
  61.         static float dotProduct(const Vector4 &v1,  const Vector4 &v2 );
  62.         static Vector4 crossProduct(const Vector4 &v1, const Vector4 &v2);
  63.  
  64.         // Operators...
  65.         Vector4 operator + (const Vector4 &other);
  66.         Vector4 operator - (const Vector4 &other);
  67.         Vector4 operator * (const Vector4 &other);
  68.         Vector4 operator / (const Vector4 &other);
  69.  
  70.         Vector4 operator * (const float scalar);
  71.         friend Vector4 operator * (const float scalar, const Vector4 &other);
  72.     
  73.         Vector4& operator = (const Vector4 &other);
  74.         Vector4& operator += (const Vector4 &other);
  75.         Vector4& operator -= (const Vector4 &other);
  76.  
  77.         Vector4 operator + (void) const;
  78.         Vector4 operator - (void) const;
  79.     };
  80.  
  81. }
  82.  
  83. #endif
  84.  
  85.